package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IUserRegisterPasswordModel;
import com.rjwh.dingdong.client.network.ApiRequest;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName UserRegisterPasswordModel
 * @Description
 * @date 2016-7-30
 * @history 2016-7-30 author: description:
 */
public class UserRegisterPasswordModel extends BaseModel implements IUserRegisterPasswordModel, HttpWebServiceCallBack {

    public UserRegisterPasswordModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    /**
     * 用户注册
     *
     * @param phoneStr 手机号
     * @param passWord 密码
     * @param codeStr  验证码
     */
    @Override
    public void doUserRegister(String phoneStr, String passWord, String codeStr) {
        Map<String, String> params = new HashMap<>();
        params.put("phone", phoneStr);
        params.put("password", passWord);
        params.put("smscode", codeStr);
        params.put("babyid", "");
        params.put("userid", "");
        HttpWebService.getDataFromServer(NetConstant.USERREGISTER, params, true, this);
    }

    /**
     * 用户登陆
     *
     * @param account   帐号
     * @param password 密码
     */
    @Override
    public void doLogin(String account, String password) {
        ApiRequest.doLogin(account, password, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null) {
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
        }
    }
}
